#include "id_component.h"

IdComponent::IdComponent(RenderTarget *parent, std::string componentId)
	: RenderTargetComponent(parent, componentId)
{
	componentType = "id";
}

void IdComponent::addTag(std::string tag)
{
	tags.insert(tag);
}

bool IdComponent::hasTag(std::string tag)
{
	//Locate tag in tags set
	std::unordered_set<std::string>::const_iterator got = tags.find(tag);
	//Return true if found (if got != tags.end())
	return !(got == tags.end());
}

void IdComponent::removeTag(std::string tag)
{
	tags.erase(tag);
}

bool IdComponent::hasProperty(std::string key)
{
	return (properties.find(key) != properties.end());
}

std::string IdComponent::getProperty(std::string key)
{
	return properties[key];
	/*
	std::map<std::string, std::string>::iterator iter = properties.find(key);
	if (iter != properties.end())
	{
		return iter->second;
	}
	return "";
	*/
}

void IdComponent::setProperty(std::string key, std::string val)
{
	properties[key] = val;
}

void IdComponent::removeProperty(std::string key)
{
	std::map<std::string, std::string>::iterator iter = properties.find(key);
	if (iter != properties.end())
		properties.erase(iter);
}
